//
//  ArticleTypeController.m
//  Village
//
//  Created by 程虎 on 2017/9/8.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "ArticleTypeController.h"
#import "PostedNewsController.h"
#import "ArticleTypeView.h"
#import "PostedViewController.h"

@interface ArticleTypeController ()

@property (nonatomic, strong) ArticleTypeView *artice;
@property (nonatomic, strong) NSArray *dataAry;
@end

@implementation ArticleTypeController

- (void)setParams:(id)obj block:(LongriseRouterBlock)block
{
    self.dataAry = (NSArray *)obj;
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
//    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.artice = [[ArticleTypeView alloc] initWithShowView:self WithData:self.dataAry];
    [self.navigationController.view addSubview:self.artice];
    WeakSelf(weakSelf);
    self.artice.nextBlock = ^(PostedType *model) {
        id obj = [LongriseRouter openURL:@"PostedViewController"];
        if([LongriseRouter isImplLongriseRouterDelegaterWithObject:obj])
        {
            id<LongriseRouterDelegater> delegater = obj;
            if(delegater)
            {
                //进行传值，传入统一的block以供B进行回调
                [delegater setParams:model block:^(id obj) {
                    
                    NSLog(@"回调数据：%@",obj);
                }];
            }
        }
        if (obj && [obj isKindOfClass:[UIViewController class]]) {
            UIViewController *VC = obj;
            UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:VC];
            [weakSelf presentViewController:nav animated:YES completion:nil];
        }
    };
}

@end
